// 这里应该实现与后端API通信的方法
// 由于没有实际的后端，我们使用模拟数据
export default {
  getStudents() {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve([
          { id: 1, name: '张三', studentId: '20230001', class: '计算机科学与技术1班', gender: '男' },
          { id: 2, name: '李四', studentId: '20230002', class: '软件工程1班', gender: '女' },
          { id: 3, name: '王五', studentId: '20230003', class: '网络工程1班', gender: '男' },
          { id: 4, name: '赵六', studentId: '20230004', class: '软件工程2班', gender: '女' },
          { id: 5, name: '孙七', studentId: '20230005', class: '计算机2班', gender: '男' },
          { id: 6, name: '周八', studentId: '20230006', class: '人工智能1班', gender: '女' },
          { id: 7, name: '吴九', studentId: '20230007', class: '信息安全1班', gender: '男' },
          { id: 8, name: '郑十', studentId: '20230008', class: '大数据1班', gender: '女' }
        ]);
      }, 500);
    });
  },

  addStudent(student) {
    return new Promise(resolve => {
      setTimeout(() => {
        student.id = Date.now();
        resolve(student);
      }, 500);
    });
  },

  getDormitories() {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve([
          { id: 101, roomNumber: '101', floor: 1, bedCount: 4, availableBeds: 2 },
          { id: 102, roomNumber: '102', floor: 1, bedCount: 4, availableBeds: 0 },
          { id: 103, roomNumber: '103', floor: 1, bedCount: 4, availableBeds: 3 },
          { id: 104, roomNumber: '104', floor: 1, bedCount: 4, availableBeds: 1 },
          { id: 201, roomNumber: '201', floor: 2, bedCount: 4, availableBeds: 4 },
          { id: 202, roomNumber: '202', floor: 2, bedCount: 4, availableBeds: 2 },
          { id: 203, roomNumber: '203', floor: 2, bedCount: 4, availableBeds: 0 },
          { id: 204, roomNumber: '204', floor: 2, bedCount: 4, availableBeds: 3 }
        ]);
      }, 500);
    });
  },

  allocateDormitory(allocation) {
    return new Promise(resolve => {
      setTimeout(() => {
        resolve({ ...allocation, date: new Date().toISOString().split('T')[0] });
      }, 500);
    });
  }
}